<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="f" %>

<sec:authorize access="isAuthenticated()">
    <%--<c:url var="logOutUrl" value="/account/logOut"/> для action можно использовать ${logOutUrl} --%>
    <f:form id="logoutForm" cssClass="navbar-right" cssStyle="margin-right: 1em;" action="${pageContext.request.contextPath}/account/logOut">
        <style>
            .navbar-content {
                width: 320px;
                padding: 15px 15px 0;
            }
        </style>
        <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Профиль <b class="caret"></b></a>

                <div class="dropdown-menu">
                    <div class="modal-body">
                        <div class="navbar-content">
                            <div class="row">
                                <div class="col-md-5">
                                    <img src="<c:url value="/resources/images/photo.png" />" alt="Alternate Text" class="img-responsive img-circle"/>

                                    <p class="text-center small">
                                        <a href="<c:url value="/account/cropPicture"/>" class="dax" data-dismiss="modal" aria-hidden="false">Изменить фото</a>
                                    </p>
                                </div>
                                <div class="col-md-7">
                                    <span><sec:authentication property="principal.displayName"/></span>

                                    <p class="text-muted small">
                                        <sec:authentication property="principal.email"/>
                                    </p>

                                    <div class="divider">
                                    </div>
                                    <a href="<c:url value="/account/viewProfile"/>" class="gax btn btn-primary btn-sm active">Просмотр профиля</a>
                                </div>
                            </div>
                        </div>
                        <div class="navbar-footer">
                            <div class="navbar-footer-content">
                                <div class="row">
                                    <div class="col-md-6">
                                        <a href="#" class="btn btn-default btn-sm">Изменить пароль</a>
                                    </div>
                                    <div class="col-md-6">
                                        <a href="javascript:document.getElementById('logoutForm').submit()" class="btn btn-default btn-sm pull-right">Выйти</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </f:form>
</sec:authorize>
<sec:authorize access="!isAuthenticated()">
    <ul class="nav navbar-nav navbar-right">
        <li><a class="dax" id="registerLink" href="<c:url value="/account/register"/>">Регистрация</a></li>
        <li><a class="dax" id="loginLink" href="<c:url value="/account/loginForm"/>">Вход</a></li>
    </ul>
</sec:authorize>

